/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.Seat;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

/**
 *
 * @author Sony
 */
@ManagedBean(name="seats")
@RequestScoped
public class SeatController {
    SeatHelper helper;
    private Seat newSeat;
    DataModel lstSeats;

    public SeatController(){
        helper = new SeatHelper();
        newSeat = new Seat();
    }
    public DataModel listSeats(){
        lstSeats = new ListDataModel(this.helper.getAllSeats());
        return lstSeats;
    }
    
    public void addSeat(){
        helper.updateSeat(newSeat);
    }
    
    public void editSeat(Seat s){
        helper.updateSeat(s);
    }
    
    public void deleteSeat(Seat s){
        helper.deleteSeat(s);
    }
    /**
     * @return the newSeat
     */
    public Seat getNewSeat() {
        return newSeat;
    }

    /**
     * @param newSeat the newSeat to set
     */
    public void setNewSeat(Seat newSeat) {
        this.newSeat = newSeat;
    }
}
